﻿using UnityEngine;
using System.Collections;

public class MainMenu : MonoBehaviour {

	public bool noob;
	public bool hardcore;
	public bool casual;
	public GameObject target;
	public AudioSource effectAudio;
	public AudioSource soundTrack;

	public Color overColor;

	private bool ready;

	IEnumerator Start()
	{
		Time.timeScale = 1;
		yield return new WaitForSeconds(1.5f);
		ready = true;
	}
	void OnMouseEnter()
	{
		if(ready)
		{
			renderer.material.color = overColor;
			effectAudio.Play();
		}
	}
	void OnMouseExit()
	{
		if(ready)
		renderer.material.color = Color.white;
	}
	void OnMouseDown()
	{
		if(ready)
		{
			target.GetComponent<Animator>().SetBool("OpenMenu",false);
			Destroy(GetComponent<BoxCollider>());
			gameObject.AddComponent("AudioFadeManager");

			if(noob)
				GetComponent<AudioFadeManager>().FadeOut(ref soundTrack,"Easy");
			if(casual)
				GetComponent<AudioFadeManager>().FadeOut(ref soundTrack,"Medium");
			if(hardcore)
				GetComponent<AudioFadeManager>().FadeOut(ref soundTrack,"Hard");
		}
	}
}
